﻿namespace System

type DayVersion =
    {   Day:       Date;
        Version:    uint32; }
    
    override this.ToString() =
        if this.Version = 0u then
            this.Day.ToString()
        else
            sprintf "%s.%i" (this.Day.ToString()) this.Version
    
    static member Parse (input: string) =
        match input.IndexOf('.') with
        | dot when dot < 0 ->
            {   Day = Date.Parse input;
                Version = 0u;   }
        | dot ->
            let date = input.Substring(0, dot)
            let version = input.Substring(dot + 1)
            {   Day = Date.Parse date;
                Version = UInt32.Parse version; }